package physics;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;


public class AchtungBall extends Ball implements KeyListener {
	
	private int turnSpeed = 130;

	public AchtungBall(int x, int y, double diameter, double mass,
			Vector initialVector) {
		super(x, y, diameter, mass, initialVector);
	}

	
	@Override
	public void act(){
		if (leftPressed)
			setVector(new Vector(getVector().getAngle() + Math.toRadians(((double) turnSpeed) / World.ACTION_RATE), getVector().getForce()));
		if (rightPressed)
			setVector(new Vector(getVector().getAngle() - Math.toRadians(((double) turnSpeed) / World.ACTION_RATE), getVector().getForce()));
		super.act();
	}



	@Override
	public void keyTyped(KeyEvent e) {
		// DO NOTHING
		
	}

	boolean leftPressed = false;
	boolean rightPressed = false;
	
	@Override
	public void keyPressed(KeyEvent e) {
		if ((e.getKeyCode() == KeyEvent.VK_LEFT)){
			leftPressed = true;
		}
		if (e.getKeyCode() == KeyEvent.VK_RIGHT){
			rightPressed = true;
		}
	
	}

	@Override
	public void keyReleased(KeyEvent e) {
		if (e.getKeyCode() == KeyEvent.VK_LEFT){
			leftPressed = false;
		}
		if (e.getKeyCode() == KeyEvent.VK_RIGHT){
			rightPressed = false;
		}
		
	}
}
